#ifndef LAURIN_NETWORK_DEVICE_H_
#define LAURIN_NETWORK_DEVICE_H_

#include "laurin-device.h"
#include "network/laurin-ip-network.h"
#include <glibmm/ustring.h>
#include <libnet.h>


/**
 * This class represent a network device characterized by its MAC and IP addresses.
 * It represent a 802.3 (ethernet) device. Note that this characterization does not exclude wireless devices.
 * In fact the wireless devices often are managed as ethernet ones. Is driver's work to encode/decode the data
 * for the 802.11X protocol.
 *
 * Before use each created object, we need to know if they are correctly configured by checking isInitialized() value.
 *
 * Packet can be sent only in the local network (if device is a wireless one, an association with the access point is needed).
 *
 * Packets injection is implemented through the libnet api. With getInjectionContext() is possible to retrieve
 * a opened libnet_t context.
 *
 *
 * For each LaurinNetworkDevice a LaurinIPNetwork is associated.
 */

class LaurinNetworkDevice : public LaurinDevice
{
	public:

		LaurinNetworkDevice(const Glib::ustring& ifaceName);
		virtual ~LaurinNetworkDevice();

		bool isInitialized() const;

		u_int32_t getIP() const;
		libnet_t* getInjectionContext() const;


		LaurinIPNetwork* getIPNetwork() const;

	protected:

		virtual bool setCaptureOptions();

	private:

		LaurinIPNetwork* _network;
		libnet_t* _injection_context;
		u_int32_t _ip;
		bool _ready;


		bool openInjectionContext();
		void closeInjectionContext();
};

#endif
